//
//  WXNotificationContextModule.swift
//  mlz
//
//  Created by 吕凌 on 2018/5/17.
//  Copyright © 2018年 吕凌. All rights reserved.
//
import Foundation

public extension WXPushServiceModule {
    
    @objc public func userInfo(_ callback: @escaping WXModuleKeepAliveCallback) {
        callback(NotificationContext.getUserInfo(), false)
    }
    
    @objc public func deviceToken(_ callback: @escaping WXModuleKeepAliveCallback) {
        callback(XGPushTokenManager.default().deviceTokenString, false)
    }
    
    @objc public func bindId(_ id: String, type: String) {
        var tokenType:XGPushTokenBindType;
        if(type == "tag") {
            tokenType = XGPushTokenBindType.tag
        } else {
            tokenType = XGPushTokenBindType.account
        }
        XGPushTokenManager.default().bind(withIdentifier: id, type: tokenType)
    }
    
    @objc public func unbindId(_ id: String, type: String) {
        var tokenType:XGPushTokenBindType;
        if(type == "tag") {
            tokenType = XGPushTokenBindType.tag
        } else {
            tokenType = XGPushTokenBindType.account
        }
        XGPushTokenManager.default().unbind(withIdentifer: id, type: tokenType)
    }
}
